<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table align="center" border="1">
    <tr>
        <td>图书名称</td>
        <td>图书作者</td>
        <td>购买时间</td>
        <td>图书分类</td>
        <td>操作</td>
    </tr>
    <tr>
        <c:forEach items="${listBook}" var="book">
        <td>${book.name}</td>
        <td>${book.author}</td>
        <td><fmt:formatDate value="${book.time}" pattern="yyyy-MM-dd"/></td>
        <td>
            <c:choose>
                <c:when test="${book.type == 1}">计算机/软件</c:when>
                <c:when test="${book.type == 2}">小说/文摘</c:when>
                <c:when test="${book.type == 3}">杂类</c:when>
                <c:otherwise>未知分类</c:otherwise>
            </c:choose>
        </td>
        <td>
            <a href="${pageContext.request.contextPath}/bookManage/viewBook?id=${book.id}">查看详细</a>
            <a href="${pageContext.request.contextPath}/bookManage/toBook?id=${book.id}">编辑</a>
            <a href="javaScript:void(0)" onclick="del(${book.id})">删除</a>
        </td>
    </tr>
    </c:forEach>
    <tr>
        <td colspan="5"><a href="${pageContext.request.contextPath}/bookManage/addBook">新增图书信息</a></td>
    </tr>
</table>
</body>
<script>
    function del(id) {
        let con = confirm("确认要删除第" + id + "行数据吗");
        if (con) {
            location = 'deleteBiz?id=' + id;
        }
    }
</script>
</html>
